<template>
  <div class="header">
    <el-form
      :label-position="right"
      label-width="100px"
      :model="formLabelAlign"
      style="max-width: 460px"
    >
      <el-form-item label="Name">
        <el-input v-model="formLabelAlign.username" />
      </el-form-item>
      <el-form-item label="Activity zone">
        <el-input v-model="formLabelAlign.password" />
      </el-form-item>
    </el-form>
  </div>
  <div class="button">
    <el-button type="primary" @click="dl">登录</el-button>
  </div>
</template>

<script>
import { defineComponent,reactive } from "vue";
import { useRouter } from 'vue-router'
import axios from 'axios'
import md5 from "js-md5"   

export default defineComponent({
  setup() {
    const router = useRouter()
    const formLabelAlign = reactive({
        username: 'admin',
        password: '123456'
    })
    function dl(){
      axios.post('http://backend-api-02.newbee.ltd/manage-api/v1/adminUser/login',{
          userName: formLabelAlign.username,
          passwordMd5:md5(formLabelAlign.password)
      }).then((res) => {
        console.log(res.data)
        if(res.data.resultCode =="200"){
          localStorage.setItem("token",res.data.data)
          router.push("/home")
        }
      })
    }
    return {
        formLabelAlign,
        dl
    };
  },
});
</script>

<style>
</style>